﻿// A dictionary is stored as a sequence of text lines containing words and their explanations.
// Write a program that enters a word and translates it by using the dictionary. 
// Sample dictionary:
//      .NET – platform for applications from Microsoft
//      CLR – managed execution environment for .NET
//      namespace – hierarchical organization of classes

using System;
using System.Collections;
using System.Collections.Generic;

public class Dictionary
{
    public static void Main()
    {
        string text = ".NET - platform for applications from Microsoft\nCLR - managed execution environment for .NET\nnamespace - hierarchical organization of classes";

        Console.Write("Enter word : ");
        string word = Console.ReadLine();

        Dictionary<string, string> dictionary = new Dictionary<string, string>();
        foreach (var line in text.Split('\n'))
        {
            string[] lineFragments = line.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
            dictionary.Add(lineFragments[0].Trim(), lineFragments[1].Trim());
        }

        string explanation;
        if (dictionary.TryGetValue(word, out explanation))
        {
            Console.WriteLine("Explanation: {0}", explanation);
        }
        else
        {
            Console.WriteLine("Explanation: Not found for this word");
        }
    }
}